#include <iostream>
#include <vector>
#include <string>

bool checkFloat(const std::string &str);

int main()
{
    while (true) {
        char buffer[256];
        std::cout << "> ";
        std::cin.getline(buffer, 256);

        std::string str(buffer);

        if (checkFloat(str))
            std::cout << "true" << std::endl;
        else
            std::cout << "false" << std::endl;
    }

    return 0;
}

std::string trim(const std::string &str)
{
    std::string whitespaces(" \t\n\r");

    auto beginPos = str.find_first_not_of(whitespaces);
    if (beginPos == std::string::npos)
        return "";

    auto endPos = str.find_last_not_of(whitespaces);
    if (endPos == std::string::npos)
        return "";

    return str.substr(beginPos, endPos - beginPos + 1);
}

std::vector<std::string> split(const std::string &str)
{
    std::string strCopy = str;

    std::vector<std::string> parts(7);
    // 将字符串分割为以下7个部分
    // part0  part1  part2  part3  part4  part5   part6
    //  -     123      .     123     e      -      123

    std::string part0to3;
    std::string part5to6;

    auto ePos = strCopy.find_first_of("eE");
    if (ePos == std::string::npos)
    {
        strCopy.append("e1");
        ePos = strCopy.size() - 2;
    }

    part0to3 = strCopy.substr(0, ePos);

    if (ePos < strCopy.size() - 1)
        part5to6 = strCopy.substr(ePos + 1, strCopy.size() - ePos - 1);

    if (!part5to6.empty())
    {
        if (part5to6[0] == '+' || part5to6[0] == '-')
        {
            parts[5] = part5to6[0];
            if (part5to6.size() > 1)
                parts[6] = part5to6.substr(1, part5to6.size() - 1);
        }
        else
            parts[6] = part5to6;
    }

    auto pointPos = part0to3.find_first_of('.');
    if (pointPos == std::string::npos)
    {
        part0to3.append(".");
        pointPos = part0to3.size() - 1;
    }

    std::string part0to1 = part0to3.substr(0, pointPos);
    if (pointPos < part0to3.size() - 1)
        parts[3] = part0to3.substr(pointPos + 1, part0to3.size() - pointPos - 1);

    if (!part0to1.empty())
    {
        if (part0to1[0] == '+' || part0to1[0] == '-')
        {
            parts[0] = part0to1[0];
            if (part0to1.size() > 1)
                parts[1] = part0to1.substr(1, part0to1.size() - 1);
        }
        else
            parts[1] = part0to1;
    }

    if (!parts[1].empty() || !parts[3].empty())
    {
        if (parts[1].empty())
            parts[1] = "0";
        if (parts[3].empty())
            parts[3] = "0";
    }

    return parts;
}

bool checkSign(const std::string &str)
{
    return str == "-" || str == "+" || str.empty();
}

bool checkNumber(const std::string &str)
{
    if (str.empty())
        return false;

    for (int i=0; i<str.size(); ++i)
    {
        if (str[i] >= '0' && str[i] <= '9')
            continue;
        else
            return false;
    }

    return true;
}

bool checkFloat(const std::string &str)
{
    std::string trimedStr = trim(str);
    if (trimedStr.find_first_of(' ') != std::string::npos)
        return false;

    std::vector<std::string> parts = split(trimedStr);
    // part0  part1  part2  part3  part4  part5   part6
    //  -     123      .     123     e      -      123

    bool ok = checkSign(parts[0])
              && checkNumber(parts[1])
              && checkNumber(parts[3])
              && checkSign(parts[5])
              && checkNumber(parts[6]);

    return ok;
}
